package com.ThreadStudy.ThinkingTest;

public class TwoThreadRun implements Runnable{


    static int sum = 50;
    @Override
    public synchronized void run() {
        while (true){
//            Thread.currentThread().getName()    // 获取当前线程的名字

            System.out.println("当前线程为"+Thread.currentThread().getName()+" 跑数字:"+sum);
            sum--;
            if(sum<=0){
                break;
            }
        }
    }


    public static void main(String[] args) {


     System.out.println("main捕获到:"+sum--);



        TwoThreadRun twoThreadRun = new TwoThreadRun();

        Thread thread = new Thread(twoThreadRun,"线程1");
        Thread thread1 = new Thread(twoThreadRun,"线程2");
        thread.start();
        thread1.start();
    }




}
